﻿@model SpotListModel
@using Nop.Web.Extensions;
@using Nop.Web.Models.WindAlert;
@{
    var CurDate = DateTime.Now;
}
<div class="panel panel-default spot-table">
    <table class="table table-hover">
        <colgroup>
            <col />
            <col />
            <col class="donot-display" />
            <col class="donot-display" />
        </colgroup>
        <thead>
            <tr>
                <th>
                    @T("Windalert.Spot.SpotTable.Spot")
                </th>
                <th>
                    @T("Windalert.Spot.SpotTable.Wind") / @T("Windalert.Spot.SpotTable.Wave")
                </th>
                <th class="donot-display">
                    <span class="glyphicon glyphicon-camera" title="@T("Windalert.Spot.SpotTable.Cameras")" />
                </th>
                <th class="donot-display">
                    <span class="glyphicon glyphicon-comment" title="@T("Windalert.Spot.SpotTable.Comments")" />
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.Spots)
            {
                <tr class="line">
                    <td><a href="@Url.RouteUrl("Spot", new { SeName = item.SeName })" class="link">@item.Name</a></td>
                    <td>
                        @if (item.Station != null)
                        {
                            <div class="wind">
                                <table>
                                    <tr>
                                        <td class="time" title="@String.Format("{0:dd/MM/yy HH:mm}", item.Station.WindData.StationAdjustedTime)">
                                            @((CurDate.AddHours(-2) > item.Station.WindData.StationAdjustedTime) ? T("Windalert.Common.NotUpdated").ToString() : String.Format("{0:HH:mm}", item.Station.WindData.StationAdjustedTime))
                                        </td>
                                        <td class="speedGust">
                                            <span class="@(item.Station.WindData.WindSpeed > 10 ? "over10knots" : "below10knots") middleAlign">@item.Station.WindData.WindSpeed</span>
                                            -
                                            <span class="@(item.Station.WindData.WindGust > 10 ? "over10knots" : "below10knots") middleAlign">@item.Station.WindData.WindGust</span>
                                        </td>
                                        <td class="direction">
                                            <img src=@("../../WindAlert/Images/DirImages/" + item.Station.WindData.WindDirectionLetters + ".png") />
                                            <span>@item.Station.WindData.WindDirectionLetters.ToUpper()</span>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        }
                        else
                        {
                            <div class="empty"></div>
                        }
                        @if (item.WaveData != null)
                        {
                            <div class="wave">
                                <table>
                                    <tr>
                                        <td class="time" title="@String.Format("{0:dd/MM/yy HH:mm}", item.WaveData.WaveAdjustedTime)">
                                            @String.Format("{0:HH:mm}", item.WaveData.WaveAdjustedTime)
                                        </td>
                                        <td class="hight">
                                            @String.Format("{0:0.0}", item.WaveData.Hs)  - @String.Format("{0:0.0}", item.WaveData.Hmax)
                                        </td>
                                        <td class="direction">
                                            @item.WaveData.DirectionLetters.ToUpper()
                                        </td>
                                        <td class="icon">
                                            <img src="../../WindAlert/Images/wave.png" />
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        }
                    </td>
                    <td class="camera donot-display">
                        @if (item.AvailableCameras.Count > 0)
                        {
                            <a href="@Url.RouteUrl("Spot", new { SeName = item.SeName })">
                                <span class="glyphicon glyphicon-camera" title="@item.Name" />
                            </a>
                        }
                    </td>
                    <td class="comment donot-display">
                        @if (item.AllowComments)
                        {
                            if (item.NumberOfComments > 0)
                            {
                                <a href="@Url.RouteUrl("Spot", new { SeName = item.SeName })">
                                    @item.NumberOfComments
                                </a>
                            }
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>


